//
//  AddressCell.m
//  NewPro
//
//  Created by RYX on 2018/10/19.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "AddressCell.h"
#import "AddressModel.h"

@interface AddressCell ()
{
    __weak IBOutlet UILabel *userLa;
    __weak IBOutlet UILabel *phoneLa;
    
    __weak IBOutlet UILabel *addressLa;
  
}
@end

@implementation AddressCell

+ (instancetype)tempWithTableView:(UITableView *)tableView{
    
    AddressCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELL"];
    if (!cell) {
        
        cell = [self cell];
    }
    
    return cell;
}


+ (CGFloat)getHeight{
    
    UITableViewCell *cell = [self cell];
    return cell.frame.size.height;
}

+ (instancetype)cell{
    
    ClassName
    return [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] objectAtIndex:0];
}

#pragma mark - 设为默认地址
- (IBAction)onSetCurrentLocal:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onSetLocalWithIndexPath:)]) {
        
        [self.delegate onSetLocalWithIndexPath:self.indexpath];
    }
}

- (void)setModel:(AddressModel *)model{
    
    userLa.text = [NSString stringWithFormat:@"收货人：%@",model.name];
    phoneLa.text = model.phone;
    addressLa.text = model.address;
    
    if ([model.isDefault intValue] == 1) {
        
        self.currentLocaBtn.selected = YES;
    }else{
        
        self.currentLocaBtn.selected = NO;
    }
    
    
}

- (IBAction)onEditBtn:(UIButton *)sender {
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(onEditBtnWithIndexPath:and:)]) {
        
        [self.delegate onEditBtnWithIndexPath:self.indexpath and:sender];
    }
}

- (IBAction)onDeleteBtn:(UIButton *)sender {
 
    if (self.delegate && [self.delegate respondsToSelector:@selector(onDeleteBtnWithIndexPath:and:)]) {
        
        [self.delegate onDeleteBtnWithIndexPath:self.indexpath and:sender];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
